package com.financing.model.invest;
import com.financing.model.base.BaseBid;
import com.financing.util.Str;

@SuppressWarnings("serial")
public class Bid extends BaseBid<Bid> {
	public static final Bid me = new Bid().dao();
	public static final String table = "bid";
	public static final String id = "id";
	public static final String name = "name";
	public static final String code = "code";
	// 年化收益率
	public static final String rate = "rate";
	// 奖励.年化收益率
	public static final String plusRate = "plus_rate";
	// 奖励.借款人
	public static final String plusBorrower = "plus_borrower";
	// 类型：新手标 first 体验标 experi  普通标 public
	public static final String type = "type";
	// 标的类型：信用 credit 抵押 mortgage 债权转让 assignment_debt 其他 other
	public static final String bidType = "bid_type";
	public static final String amount = "amount";
	public static final String status = "status";
	public static final String createTime = "create_time";
	// 分润模板id
	public static final String templateId = "template_id";
	// 自动上标时间
	public static final String submitTime = "submit_time";
	public static final String startTime = "start_time";
	public static final String endTime = "end_time";
	public static final String investStartTime = "invest_start_time";
	public static final String investEndTime = "invest_end_time";
	// 还款方式：一次还本付息 all 按期付息到期还本 schedule 等额本息 interest 等额本金 capital
	public static final String repayType = "repay_type";
	public static final String guarantee = "guarantee";
	// 是否推荐：1 推荐 0 不推荐
	public static final String recommand = "recommand";
	public static final String enable = "enable";
	// 周期时长 
	public static final String dayLimit = "day_limit";
	// 总划分单元 
	public static final String unit = "unit";
	// 已购买单元
	public static final String applyUnit = "apply_unit";
	// 最少购买单元
	public static final String leastUnit = "least_unit";
	// 每单元单价
	public static final String unitAmount = "unit_amount";
	// 备注
	public static final String summary = "summary";
	// 展示顺序
	public static final String dsporder = "dsporder";
	// 借款人
	public static final String borrower = "borrower";
	// 虚拟份数
	public static final String virtualUnit = "virtual_unit";
	// 是否正在投资中
	public static final String isTrading = "is_trading";
	// 违约代偿状态：0 毋须代偿 1 平台已代偿，借款方未偿还 2 平台已代偿，借款方已偿还
	public static final String compensatory = "compensatory";
	// 违约代偿状态：0 毋须代偿 1 平台已代偿，借款方未偿还 2 平台已代偿，借款方已偿还
	public static final String allVirtual = "all_virtual";

	
	public boolean isExperi() {
		return Str.eq("experi", getType());
	}
	
	public int getApplyPerid() {
		// 查找最新需要还的期数
		return Repay.me.findFirst("select apply_period from repay where status='process' and bid_id=? group by apply_period order by apply_period asc",getId()).getApplyPeriod();
	}
}